package com.capgemini.scaffold.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ShuHao.Wen
 * @since 2022/10/21
 */
@Configuration
@Slf4j
public class MvcConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new RefreshTokenInterceptor())
                .excludePathPatterns(
                        "/user/login/",
                        "/user/signIn/",
                        "/intern/queryInternPage",
                        "/intern/queryTutorPage",
                        "/csrf/**",
                        "/webjars/**",
                        "/swagger-resources/**",
                        "/v2/**",
                        "/swagger-ui.html/**",
                        "/**.css",
                        "/**.html",
                        "/**.png",
                        "/**.jpg",
                        "/**.js"
                ).order(0);
        //注册拦截类 拦截部分请求
        registry.addInterceptor(new LoginInterceptor())
                .excludePathPatterns(
                        "/user/login/",
                        "/user/signIn/",
                        "/intern/queryInternPage",
                        "/intern/queryTutorPage",
                        "/csrf/**",
                        "/webjars/**",
                        "/swagger-resources/**",
                        "/v2/**",
                        "/swagger-ui.html/**",
                        "/**.css",
                        "/**.html",
                        "/**.png",
                        "/**.jpg",
                        "/**.js"
                ).order(1);


    }


}
